<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
	<title>Document</title>
	<script src="../lib/vue.js"></script>
	<style>
	</style>
</head>
<body>
	<div id="box">
		<input type="text" v-model="msg">
		<span v-text="msg | toDouble"></span>

	</div>
	
	<script>
		Vue.filter("toDouble",function(input){
			var reg = /^[0-9]*$/;
			if (reg.test(input)) {
				return this.msg < 10 ? "0"+input : input;
			}else{
				console.log("请输入数字");
				this.msg = "";
			};
			
		});
		var vm = new Vue({
			el: "#box",
			data: {
				msg:2
			}
		});
	</script>
</body>
</html>